export default () => {
  const safeNavigateBack = () => {
    const pages = getCurrentPages();
    if (pages.length > 1) {
      uni.navigateBack();
    } else {
      uni.switchTab({ url: '/pages/index/index' });
    }
  };

  return { safeNavigateBack };
};
